package java.lang;

/**
 * Created by francis on 2018/1/21.
 */
public class Main {
    public static void main(String[] args) throws ClassNotFoundException {
        loadOtherJarClassUsing();
    }
//    //使用系统类加载器加载类
//    private static void loadClassAUsingSystemLoader() throws ClassNotFoundException {
//        Class<?> a = Main.class.getClassLoader().loadClass("java.lang.ClassA");
//        System.out.println(a.getName());
//    }
//
//    //使用自定义加载器加载类
//    private static void loadClassAUsingMyLoader() throws ClassNotFoundException {
//        Class<?> a = new MyClassLoader().loadClass("java.lang.ClassA");
//        System.out.println(a.getName());
//    }

    private static void loadOtherJarClassUsing() throws ClassNotFoundException {
        Class<?> a = new MyClassLoader().loadClass("org.apache.commons.io.IOUtils");
        System.out.println(a.getName());
    }
}

